    <!-- 列表CNKI -->
      <template>
  <div class="gd-listCnki">
    <div class="top">
      <div class="le"></div>
      <div class="font">CNKI知识</div>
    </div>
    <div class="bot">
      <ul>
        <li @click="goToDetail(item)" v-for="(item,index) in cnkiList" :key="index">
          <div class="img">
            <span class="iconfont">&#xe625;</span> 
          </div>
          <div class="bot">
                {{item.DatabaseName}}
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { getCNKI } from "@/api/home";

export default {
  name: "information",
  data() {
    return {
      cnkiList:[],
    };
  },
  created() {
    this.init();
  },
  filters: {
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 20) {
        return value.slice(0, 20) + "...";
      }
      return value;
    },
  },
  methods: {
    init() {
      getCNKI().then(res=> {
          let str =  JSON.parse(res.data.data);
          this.cnkiList = str.split(","); 
          this.cnkiList = this.cnkiList.map(i=>{
              let obj = {};
             obj.DatabaseName = i.substring(0,i.indexOf(":"));
             obj.DatabaseCode = i.substring(i.indexOf(":")+1,i.length);
             return obj
          })  
      })
    }, 
    goToDetail(item){   
       this.$router.push({path:"/singleSearch",query:{
         type:"home",
         data:JSON.stringify({
           type:2,
           pagenow:1,
           pagesize:10, 
           wherestr: "",
           orderstr:"relevant", 
           dbcode:item.DatabaseCode,
         }),
       }});
    },
  },
};
</script>
<style lang="scss" scoped>
@import "../../../assets/css/listCnki.css"; 
.gd-listCnki .top{
  // border-bottom:1px solid #bbb;
}
</style>